using Sirenix.OdinInspector;
using UnityEngine;
using UnityEngine.Rendering;

namespace Game.Scripts.Entity.UI
{
    public class GameMenuBase : MonoBehaviour
    {
        [SerializeField] private GameObject components;
        [SerializeField] private Volume volume;
        private float originalFocalLength;
        private UnityEngine.Rendering.Universal.DepthOfField depthOfField;

        private void Awake()
        {
            if (volume.profile.TryGet(out depthOfField))
            {
                originalFocalLength = depthOfField.focalLength.value;
            }
            else
            {
                Debug.Log("post processing volume is not config correctly", this);
            }
        }


        [ButtonGroup]
        private void ShowUI()
        {
            Open();
        }


        [ButtonGroup]
        private void HideUI()
        {
            Close();
        }


        public virtual void Open()
        {
            components.SetActive(true);
        }

        public virtual void Close()
        {
            components.SetActive(false);
        }


        public void BackGroundBlur()
        {
            depthOfField.focalLength.value = 300f;
        }

        public void UndoBlur()
        {
            depthOfField.focalLength.value = originalFocalLength;
        }
    }
}